package da.asclass.events.net
{
    import da.asclass.util.Constant;

    import flash.events.Event;
    import flash.events.EventDispatcher;
    import flash.events.IEventDispatcher;

    public class SendMessageEvent extends Event
    {
        public static const type:String = "SEMD_MESSAGE_EVENT";
        private var _fromUserID:String = null;
        private var _toUserID:String = null;
        private var _content:String = null;
        private var _cmd:String = null;
        private var myDisp:EventDispatcher = null;

        public function SendMessageEvent ()
        {
            super( SendMessageEvent.type );
        }

        public function getMessage ():String
        {
            var msg:String = null;
            msg = this.cmd + this.fromUserID + this.toUserID + this.content;
            return msg;
        }

        public function set cmd ( c:String ):void
        {
            if ( c.length != Constant.CMD_LENGTH )
            {
                for ( var i:int = c.length ; i < Constant.CMD_LENGTH ; ++i )
                {
                    c = Constant.ADD_TO_HEAD + c;
                }
            }
            this._cmd = c;
        }

        public function get cmd ():String
        {
            return this._cmd;
        }

        public function set fromUserID ( f:String ):void
        {
            if ( f.length < Constant.USER_ID_LENGTH )
            {
                for ( var i:int = f.length ; i < Constant.USER_ID_LENGTH ; ++i )
                {
                    f = Constant.ADD_TO_HEAD + f;
                }
            }
            this._fromUserID = f;
        }

        public function get fromUserID ():String
        {
            return this._fromUserID;
        }

        public function set toUserID ( t:String ):void
        {
            if ( t.length < Constant.USER_ID_LENGTH )
            {
                for ( var i:int ; i < Constant.USER_ID_LENGTH ; ++i )
                {
                    t = Constant.ADD_TO_HEAD + t;
                }
            }
            this._toUserID = t;
        }

        public function get toUserID ():String
        {
            return this._toUserID;
        }

        public function set content ( c:String ):void
        {
            this.content = c;
        }

        public function get content ():String
        {
            return this._content;
        }

    }
}